sgdk: sprite_eng.h File Reference

sgdk

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

Classes | Defines | Functions
sprite_eng.h File Reference

Sprite engine. More...

`#include "vdp_pal.h"`
`#include "vdp_tile.h"`
`#include "vdp_spr.h"`

Go to the source code of this file.

## Classes

struct | VDPSprite
struct | FrameSprite
struct | AnimationFrame
struct | Animation
struct | SpriteDefinition
struct | Sprite

## Defines

#define | SPRITE_CACHE_SIZE 128
#define | COLLISION_TYPE_NONE 0
#define | COLLISION_TYPE_BOX 1
#define | COLLISION_TYPE_CIRCLE 2

## Functions

void | SPR_init (u16 cacheSize)
| Init the Sprite engine.
void | SPR_end ()
| End the Sprite engine.
u16 | SPR_isInitialized ()
| FALSE if sprite cache engine is not initialized.
void | SPR_initSprite (Sprite *sprite, SpriteDefinition *spriteDef, s16 x, s16 y, u16 attribut)
| Initialize the specified Sprite. By default a sprite use automatic VRAM tile allocation but you can fix it by using the SPR_setVRAMTileIndex(..) method.
void | SPR_setPosition (Sprite *sprite, s16 x, s16 y)
| Set sprite position.
void | SPR_setAttribut (Sprite *sprite, u16 attribut)
| Set sprite attribut.
void | SPR_setAnimAndFrame (Sprite *sprite, s16 anim, s16 frame)
| Set current sprite animation and frame.
void | SPR_setAnim (Sprite *sprite, s16 anim)
| Set current sprite animation.
void | SPR_setFrame (Sprite *sprite, s16 frame)
| Set current sprite frame.
void | SPR_nextFrame (Sprite *sprite)
| Pass to the next sprite frame.
void | SPR_setVRAMTileIndex (Sprite *sprite, s16 index)
| Set the VRAM tile position for this sprite.
void | SPR_setAlwaysVisible (Sprite *sprite, u16 value)
| Set the always visible flag this sprite. By setting it to TRUE the sprite is considered as always visible and won't require any visibility computation.
void | SPR_setNeverVisible (Sprite *sprite, u16 value)
| Set the never visible flag this sprite. By setting it to TRUE the sprite is considered as always hidden and won't be displayed.
void | SPR_clear ()
| Test if specified sprites are in collision.
void | SPR_update (Sprite *sprites, u16 num)
| Update and display the specified list of sprite. This actually prepare the list cache and send it to the hardware (VDP) at Vint.

## Detailed Description

Sprite engine.

Author:
  Stephane Dallongeville

Date:
  10/2013

Sprite engine providing advanced sprites manipulation and operations.
This unit use both the tile cache engine (see tilecache.h file for more info)
and the Sega Genesis VDP sprite capabilities (see vdp_spr.h file for more info).

## Define Documentation

#define COLLISION_TYPE_BOX 1

Bouding box collision tpye

#define COLLISION_TYPE_CIRCLE 2

Round circle collision tpye

#define COLLISION_TYPE_NONE 0

No collision tpye

#define SPRITE_CACHE_SIZE 128

Maximum number of sprite in the cache

## Function Documentation

void SPR_clear | ( |  | ) |

Test if specified sprites are in collision.

Parameters:

  sprite1 | first sprite.
  sprite2 | second sprite.

Returns:
  TRUE if sprite1 and sprite2 are in collision, FALSE otherwise.

Clear all displayed sprites.
This actually clear the list cache and send it to the hardware (VDP) at Vint.

void SPR_end | ( |  | ) |

End the Sprite engine.

End the sprite engine.
This actually release memory allocated for sprite cache and release the tile cache engine if it was started by Sprite engine.

void SPR_init | ( | u16 | cacheSize | ) |

Init the Sprite engine.

Parameters:

  cacheSize | size of the tile cache (in tile) for the automatic tile allocation. If set to 0 the default size is used (384 tiles)

Initialize the sprite engine.
This actually allocate memory for sprite cache and initialize the tile cache engine if this is not alreay done.

void SPR_initSprite | ( | Sprite * | sprite,
|  | SpriteDefinition * | spriteDef,
|  | s16 | x,
|  | s16 | y,
|  | u16 | attribut
| ) |  |

Initialize the specified Sprite.
By default a sprite use automatic VRAM tile allocation but you can fix it by using the SPR_setVRAMTileIndex(..) method.

Parameters:

  sprite | Sprite to initialize.
  spriteDef | the SpriteDefinition data to assign to this sprite.
  x | default X position.
  y | default Y position.
  attribut | sprite attribut (see TILE_ATTR() macro).

void SPR_nextFrame | ( | Sprite * | sprite | ) |

Pass to the next sprite frame.

Parameters:

  sprite | Sprite to pass to next frame for

void SPR_setAlwaysVisible | ( | Sprite * | sprite,
|  | u16 | value
| ) |  |

Set the always visible flag this sprite.
By setting it to TRUE the sprite is considered as always visible
and won't require any visibility computation.

Parameters:

  sprite | Sprite to set the always visible flag
  value | The always visible flag value (TRUE or FALSE)

See also:
  SPR_setNeverVisible(..)

void SPR_setAnim | ( | Sprite * | sprite,
|  | s16 | anim
| ) |  |

Set current sprite animation.

Parameters:

  sprite | Sprite to set animation for
  anim | animation index to set.

void SPR_setAnimAndFrame | ( | Sprite * | sprite,
|  | s16 | anim,
|  | s16 | frame
| ) |  |

Set current sprite animation and frame.

Parameters:

  sprite | Sprite to set animation and frame for
  anim | animation index to set
  frame | frame index to set

void SPR_setAttribut | ( | Sprite * | sprite,
|  | u16 | attribut
| ) |  |

Set sprite attribut.

Parameters:

  sprite | Sprite to set attribut for
  attribut | attribut (see TILE_ATTRIBUT() macro)

void SPR_setFrame | ( | Sprite * | sprite,
|  | s16 | frame
| ) |  |

Set current sprite frame.

Parameters:

  sprite | Sprite to set frame for
  frame | frame index to set.

void SPR_setNeverVisible | ( | Sprite * | sprite,
|  | u16 | value
| ) |  |

Set the never visible flag this sprite.
By setting it to TRUE the sprite is considered as always hidden
and won't be displayed.

Parameters:

  sprite | Sprite to set the never visible flag
  value | The never visible flag value (TRUE or FALSE)

See also:
  SPR_setAlwaysVisible(..)

void SPR_setPosition | ( | Sprite * | sprite,
|  | s16 | x,
|  | s16 | y
| ) |  |

Set sprite position.

Parameters:

  sprite | Sprite to set position for
  x | X position
  y | Y position

void SPR_setVRAMTileIndex | ( | Sprite * | sprite,
|  | s16 | index
| ) |  |

Set the VRAM tile position for this sprite.

Parameters:

  sprite | Sprite to set the VRAM tile position for
  index | the tile position in VRAM where we will upload the sprite tiles. Set to -1 for automatic allocation (default).

void SPR_update | ( | Sprite * | sprites,
|  | u16 | num
| ) |  |

Update and display the specified list of sprite.
This actually prepare the list cache and send it to the hardware (VDP) at Vint.

Parameters:

  sprites | sprites we want to prepare and display.
  num | number of sprites in the list.

All Classes Files Functions Variables Typedefs Enumerations Defines